<?php
error_reporting(0);
$isadmin=1;
include_once '../comm/config.php';
include '../comm/checkpostandget.php';
include '../comm/msgset.php';
include 'check.php';
$id=$_POST['id'];
$ddusername=$_POST['ddusername'];
$dduserid=$_POST['dduserid'];
$why=$_POST['why'];  
$trade_id=$_POST['trade_id'];  

$q = "select * from ".$BIAOTOU."tradelist where Id=".$id;
$query=mysql_query($q);
$row = mysql_fetch_array($query);
$id=$row['Id'];
$checked=$row['checked'];
if(!$id)
{
	echo "错误：未找到该记录！";
	exit;
}
else
{
	if($checked==1)
	{
		$q = "update ".$BIAOTOU."tradelist set checked=0,outer_code='' where id=".$id;
		mysql_query($q);
		$sj= date("Y-m-d H:i:s");
		$msg_tuihuitrade="您提交的订单".$trade_id."未通过审核，请联系网站客服，谢谢！".$why;
		$insert = "INSERT into ".$BIAOTOU."msg(ddusername,title,content,addtime,senduser) values ('$ddusername','订单审核失败','".$msg_tuihuitrade."','$sj','网站客服')";
		mysql_query($insert);
	}
	else
	{
		echo "该订单未处在审核状态，无法回退！<a href=checktradelist.php>返回</a>";
		exit;
	}
}

admin_log('退回审核订单');
mysql_close();
header('Location: checktradelist.php'); 
?>